﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CourseSystem.Core.Entities;
using CourseSystem.Core.Enum;

namespace CourseSystem.Common.Helpers
{
    public class InterActionHelper
    {
        public static bool IsHasPower(PostsInfo info)
        {
            var user = UserHelper.LoginUser;
            if (user == null || user.IsExpert)
                return false;
            if (user.UserType == UserTypeEnum.Admin || user.UserType == UserTypeEnum.Teacher)
                return true;
            if (info.TopicsInfo.IsDigest)
                return false;
            if ((byte)user.UserType == info.PosterType && user.Id == info.PosterId)
                return true;
            return false;
        }

        public static bool IsHasDelPower(PostsInfo info)
        {
            var user = UserHelper.LoginUser;
            if (user == null || user.IsExpert)
                return false;
            if (user.UserType == UserTypeEnum.Admin || user.UserType == UserTypeEnum.Teacher)
                return true;
            return false;
        }
    }
}
